﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SyncColor : MonoBehaviour
{
    private SpriteRenderer spriteRenderer;
    private Material material;

    void Start()
    {
        spriteRenderer = GetComponent<SpriteRenderer>();
        material = spriteRenderer.material; // 获取独立材质
        SyncColorNow(); // 初始化同步
    }

    void Update()
    {
        SyncColorNow(); // 实时同步（可选）
    }

    void SyncColorNow()
    {
        material.SetColor("_Color", spriteRenderer.color);
    }
}
